<?php
final class hash{

	private function __construct(){}

	public function & merge() {
		$args = func_get_args();
		$ary	= array();
		foreach($args as $i=>&$a){
			if( !is_array($a) ){
				throw new Exception('argv ' . ($i+1) . ' is not array');
			}
			foreach($a as $k=>$v){
				if( isset($ary[$k]) &&  is_array($ary[$k])  && is_array($v) ){
					$ary[$k] = self::merge($ary[$k], $v);
				}else{
					$ary[$k] = $v;
				}
			}
			unset($v);
		}
		unset($a);
		return $ary; 
	}

	public static function & link($types, &$args){
		$result	= array();
		foreach($args as $val){
			foreach($types as $key => $type){
				if( gettype($val) === $type ){
					$result[$key] = $val;
					unset($types[$key]);
					break;
				}
			}
		}
		return $result;
	}

	public static function args($types, &$args ){
		file_put_contents($file , '<?php $' . $name . '= ' . var_export($ary, 1) . ';?' . '>');
	}

	public static function save(&$ary, $file ){
		file_put_contents($file , '<?php return ' . var_export($ary, 1) . ';?' . '>');
	}

}
?>